<?php

require_once 'BaseMapper.php';
class Application_Model_EventoMapper extends BaseMapper
{

    public function __construct()
    {
        parent::setDbTable(new Application_Model_DbTable_Evento());
        parent::setExtendedModel(new Application_Model_Evento());
    }

    public function fetchByPorcino($id_porcino)
    {
        $table = Zend_Db_Table::getDefaultAdapter();
        $select = $table->select()
            ->from(array('e' => 'evento'), array('*'))
            ->joinInner(array('te' => 'tipo_evento'), "e.tipo_evento_id = te.id", array('nombre'))
            ->where('e.porcino_id=' . $id_porcino);

        $resultSet = $table->fetchAll($select);

        $entries = array();
        foreach ($resultSet as $row) {
            $mapped = $this->map($row);
            $mapped->addOtherColumn(array("nombre" => $row['nombre']));
            $entries[] = $mapped;
        }
        return $entries;
    }
}

